package org.jeeasy.generate.domain.vo;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import org.springframework.ai.converter.BeanOutputConverter;

import java.util.List;

@Data
public class AiGenTableVO {

    public static void main(String[] args) {

        BeanOutputConverter<AiGenTableVO> outputConverter = new BeanOutputConverter<>(AiGenTableVO.class);

        String format = outputConverter.getFormat();
        System.out.println(format);
    }

    // 表名
    //@JsonProperty("name")
    @JsonProperty(required = true)
    private String tableName;
    // 表摘要
    //@JsonProperty("summary")
    @JsonProperty(required = true)
    private String tableSummary;
    // 表描述
    //@JsonProperty("description")
    @JsonProperty(required = true)
    private String tableComment;
    // 字段列表
    //@JsonProperty("tableFields")
    @JsonProperty(required = true)
    private List<Column> columns;

    @Data
    static class Column {
        // 字段名
        @JsonProperty(required = true)
        private String columnName;
        // 数据类型，例如: double(10, 2)
        @JsonProperty(required = true)
        private String jdbcType;
        // 字段长度，例如: 10
        @JsonProperty(required = true)
        private Integer columnLength;
        // 小数精度，例如: 2
        private Integer columnPrecision;
        // 字段描述
        //@JsonProperty("description")
        @JsonProperty(required = true)
        private String columnComment;
        // 展示名称
        //@JsonProperty("showName")
        @JsonProperty(required = true)
        private String shortColumnComment;
        // 默认值
        private String defaultValue;
        // 允许空值
        @JsonProperty(defaultValue = "true")
        private Boolean allowNull = true;
        /**
         * java类型
         */
        @JsonProperty(required = true)
        private JavaFieldType javaType;
        // 新增时是否显示
        @JsonProperty(defaultValue = "true")
        private Boolean showAdd = true;
        // 修改时是否显示
        @JsonProperty(defaultValue = "true")
        private Boolean showEdit = true;
        // 列表中是否显示
        @JsonProperty(defaultValue = "true")
        private Boolean showTable = true;
        // 新增时是否禁用
        @JsonProperty(defaultValue = "false")
        private Boolean disableOnAdd = false;
        // 修改时是否禁用
        @JsonProperty(defaultValue = "false")
        private Boolean disableOnEdit = false;
        // 是否可以条件查询
        @JsonProperty(defaultValue = "false")
        private Boolean showSearch = false;
        /**
         * 表单录入的控件类型
         */
        @JsonProperty(required = true)
        private FormInputType formType = FormInputType.TEXT;
        // 是否必填校验
        @JsonProperty(defaultValue = "false")
        private Boolean required = false;
    }

    @Getter
    @AllArgsConstructor
            //@JsonFormat(shape = JsonFormat.Shape.OBJECT)
    enum JavaFieldType {
        STRING,
        INTEGER,
        LONG,
        DOUBLE,
        FLOAT,
        BOOLEAN,
        BIG_DECIMAL,
        LOCAL_DATE,
        LOCAL_DATETIME,
        LOCAL_TIME;

        //STRING("String"),
        //INTEGER("Integer"),
        //DOUBLE("Double"),
        //LONG("Long"),
        //FLOAT("Float"),
        //BIG_DECIMAL("BigDecimal"),
        //LOCAL_DATE("LocalDate"),
        //LOCAL_DATETIME("LocalDateTime"),
        //LOCAL_TIME("LocalTime");
        //
        //private final String type;
    }

    @Getter
    @AllArgsConstructor
            //@JsonFormat(shape = JsonFormat.Shape.OBJECT)
    enum FormInputType {
        TEXT,
        TEXT_AREA,
        INPUT_NUMBER,
        DATE,
        TIME,
        DATETIME,
        SWITCH,
        SELECT;

        //TEXT("text"),
        //TEXT_AREA("textArea"),
        //INPUT_NUMBER("inputNumber"),
        //DATE("date"),
        //TIME("time"),
        //DATETIME("datetime"),
        //SWITCH("switch"),
        //SELECT("select");
        //
        //private final String type;
    }
}
